package com.ws.universal.tools.wsui.headle;

import android.content.res.ColorStateList;
import android.view.View;

import com.ws.universal.tools.wsui.help.IQMUILayout;
import com.ws.universal.tools.wsui.help.QMUISkinHelper;
import com.ws.universal.tools.wsui.widget.QMUIRadiusImageView;
import com.ws.universal.tools.wsui.widget.QMUIRoundButton;
import com.ws.universal.tools.wsui.widget.QMUISlider;

import org.jetbrains.annotations.NotNull;

public class QMUISkinRuleBorderHandler extends QMUISkinRuleColorStateListHandler {
    @Override
    protected void handle(@NotNull View view, @NotNull String name, ColorStateList colorStateList) {
        if (colorStateList == null) {
            return;
        }
        if (view instanceof IQMUILayout) {
            ((IQMUILayout) view).setBorderColor(colorStateList.getDefaultColor());
        } else if (view instanceof QMUIRadiusImageView) {
            ((QMUIRadiusImageView) view).setBorderColor(colorStateList.getDefaultColor());
        } else if (view instanceof QMUIRoundButton) {
            ((QMUIRoundButton) view).setStrokeColors(colorStateList);
        } else if (view instanceof QMUISlider.DefaultThumbView) {
            ((QMUISlider.DefaultThumbView) view).setBorderColor(colorStateList.getDefaultColor());
        } else {
            QMUISkinHelper.warnRuleNotSupport(view, name);
        }
    }
}
